import {
  request
} from '../utils/request';

// 查询官方/用户组群列表
let getGroupList = (types, pageNum, pageSize) => {
  return request({
    url: `/groups/list/${types}`,
    data: {
      pageNum: pageNum,
      pageSize: pageSize
    }
  });
}

// 查询官方/用户组群列表
let newGetGroupList = (pageNum, pageSize) => {
  return request({
    url: '/groups/list',
    data: {
      pageNum: pageNum,
      pageSize: pageSize
    }
  });
}

// 获取官方组群首页信息
let officialGroupDetails = (groupId) => {
  return request({
    url: `/official/group/${groupId}`
  });
}

// 查询群组名片成员列表
let getGroupMemberList = (groupId, pageNum, pageSize) => {
  return request({
    url: `/groups/cardList/${groupId}`,
    data: {
      pageNum: pageNum,
      pageSize: pageSize
    }
  });
}

// 创建用户群
let createUserGroup = (masterCId, title, checked, image) => {
  return request({
    url: '/groups/add',
    method: 'POST',
    data: {
      masterCId: masterCId,
      title: title,
      checked: checked,
      image: image
    }
  });
}

// 修改用户群
let editUserGroup = (groupId, title, checked, image, remark) => {
  return request({
    url: '/groups/edit',
    method: 'POST',
    data: {
      groupId: groupId,
      title: title,
      checked: checked,
      image: image,
      remark: remark
    }
  });
}

// 更换加入用户群的名片
let changeJoinGroupCard = (groupId, cardId) => {
  return request({
    url: `/groups/replaceCard/${groupId}/${cardId}`
  });
}

// 删除群组
let deleteGroup = (groupId) => {
  return request({
    url: `/groups/remove/${groupId}`
  });
}

// 删除群组成员
let deleteGroupMember = (groupId, cardId) => {
  return request({
    url: `/groups/removeCard/${groupId}/${cardId}`
  });
}

// 申请加入群组
let applyJoinGroup = (groupId, cardId, reason) => {
  return request({
    url: `/groups/applyJoin/${groupId}/${cardId}`,
    data: {
      reason: reason
    }
  });
}

// 直接加入群组
let directJoinGroup = (groupId, cardId) => {
  return request({
    url: `/groups/join/${groupId}/${cardId}`
  });
}

// 群主审核要加入群组的名片
let masterExamine = (groupCardId, checked) => {
  return request({
    url: `/groups/agree/join/${groupCardId}/${checked}`
  });
}

// 发起名片交换
let exchangeCard = (groupId, cardId) => {
  return request({
    url: `/groups/exchange/${groupId}/${cardId}`
  });
}

// 回复名片交换
let replyExchangeCard = (exchangeId, agree) => {
  return request({
    url: `/groups/agreeExchange/${exchangeId}/${agree}`
  });
}

// 查询申请名片交换列表
let exchangeCardList = (pageNum, pageSize) => {
  return request({
    url: '/groups/exchangeList',
    data: {
      pageNum: pageNum,
      pageSize: pageSize
    }
  });
}

// 消息，红点数字提示
let notice = () => {
  return request({
    url: '/groups/notice'
  });
}

// 消息通知-审核加入消息列表
let joinGroupNotice = (pageNum, pageSize) => {
  return request({
    url: '/groups/notice/joinList',
    data: {
      pageNum: pageNum,
      pageSize: pageSize
    }
  });
}

// 用户进群申请列表
let joinGroupApplyList = (data = {}) => {
  return request({
    url: '/groups/apply/joinList',
    data: {
      ...data
    }
  });
}

// 获取组群二维码-简单信息
let groupQRcode = (groupId) => {
  return request({
    url: `/groups/get/${groupId}`
  });
}

// 获取可以受邀请的名片列表
let allowInviteList = (groupId, keyWord) => {
  return request({
    url: `/groups/canInvite/cardList/${groupId}`,
    data: {
      keyWord: keyWord
    }
  });
}

// 邀请关联的名片加入群组
let inviteCardJoinGroup = (groupId, relCardId, reason) => {
  return request({
    url: '/groups/invite/userCard',
    method: 'POST',
    data: {
      groupId: groupId,
      relCardId: relCardId,
      reason: reason
    }
  });
}

// 统计名片点击次数
let clickNum = (groupId, cardId) => {
  return request({
    url: `/groups/click/${groupId}/${cardId}`
  });
}

// 名片人气榜
let cardRank = (groupId) => {
  return request({
    url: `/groups/rank/${groupId}`
  });
}

// 退出群组
let signoutGroup = (groupId, cardId) => {
  return request({
    url: `/groups/signOut/${groupId}/${cardId}`
  });
}

// 获取官方组群首页轮播图和推荐群
let getOfficialGroupSwiper = (groupId) => {
  return request({
    url: `/groups/${groupId}`
  });
}

// 获取官方组群首页轮播图和推荐群
let getLabelList = () => {
  return request({
    url: '/label/level/list'
  });
}

// 查询群组名片成员列表
let searchMember = (groupId, pageNum, pageSize, keyword) => {
  return request({
    url: `/groups/cardList/${groupId}`,
    data: {
      pageNum: pageNum,
      pageSize: pageSize,
      keyWord: keyword
    }
  });
}

// 群组名片墙
let groupCardWall = (data = {}) => {
  return request({
    url: `/groups/wallList/${data.groupId}`,
    method: 'POST',
    data: {
      ...data
    }
  });
}

module.exports = {
  getGroupList,
  officialGroupDetails,
  getGroupMemberList,
  createUserGroup,
  editUserGroup,
  changeJoinGroupCard,
  deleteGroup,
  deleteGroupMember,
  applyJoinGroup,
  directJoinGroup,
  masterExamine,
  exchangeCard,
  replyExchangeCard,
  exchangeCardList,
  notice,
  joinGroupNotice,
  joinGroupApplyList,
  groupQRcode,
  allowInviteList,
  inviteCardJoinGroup,
  clickNum,
  cardRank,
  signoutGroup,
  getOfficialGroupSwiper,
  getLabelList,
  searchMember,
  groupCardWall,
  newGetGroupList
}